import com.java4less.rchart.Chart;
import com.java4less.rchart.ChartLoader;
import com.java4less.rchart.gc.ChartGraphics;
import com.java4less.rchart.gc.ChartImage;
import com.java4less.rchart.gc.GraphicsProvider;
import com.java4less.rchart.gc.svg.ChartBatikImage;
import java.io.FileOutputStream;



public class Chart2SVG {

	public static void main(String[] args) {
		try {

		GraphicsProvider.setMode(GraphicsProvider.MODE_AWT_SWING);

		ChartLoader cha=new ChartLoader(null);
		
		cha.setParameter("TITLECHART","Sales 1999");
		cha.setParameter("LEGEND","TRUE"); 
		cha.setParameter("XLABEL","Month"); 
		cha.setParameter("YLABEL","Million $"); 
		cha.setParameter("XAXIS_LABELS","June|July|Aug.|Sept.|Oct.|Nov.|Dec.");
		cha.setParameter("SERIE_1","Products");
		cha.setParameter("SERIE_2","Services");
		cha.setParameter("SERIE_STYLE_1","0.2|RED|LINE");
		cha.setParameter("SERIE_FONT_1","Arial|PLAIN|8");
		cha.setParameter("SERIE_FONT_2","Arial|PLAIN|8");
		cha.setParameter("SERIE_COLOR_1","RED");
		cha.setParameter("SERIE_COLOR_2","BLUE");
		cha.setParameter("SERIE_POINT_COLOR_1","RED");
		cha.setParameter("SERIE_POINT_COLOR_2","BLUE");
		cha.setParameter("SERIE_POINT_1","true");
		cha.setParameter("SERIE_POINT_2","true");
		cha.setParameter("SERIE_STYLE_2","0.2|BLUE|LINE");
		cha.setParameter("SERIE_DATA_1","12|43|50|45|30|32|42");
		cha.setParameter("SERIE_DATA_2","20|41|48|39|36|34|50");
		cha.setParameter("SERIE_TYPE_1","LINE");
		cha.setParameter("SERIE_TYPE_2","LINE");
		cha.setParameter("CHART_BORDER","0.2|BLACK|LINE");
		cha.setParameter("CHART_FILL","LIGHTGRAY");
		cha.setParameter("BIG_TICK_INTERVALX","1");
		cha.setParameter("BIG_TICK_INTERVALY","10");
		cha.setParameter("YSCALE_MIN","0");
		cha.setParameter("LEGEND_BORDER","0.2|BLACK|LINE");
		cha.setParameter("LEGEND_FILL","WHITE");
		cha.setParameter("XAXIS_GRID","0.2|WHITE|DASHED");
		cha.setParameter("YAXIS_GRID","0.2|WHITE|DASHED");
		cha.setParameter("XAXIS_TICKATBASE","true");
		
		
	
		cha.setParameter("CHART_FILL","YELLOW");
		cha.setParameter("YLABEL_VERTICAL","TRUE");
		/* process parameters and create chart*/
		Chart c=cha.build(false,true);
		c.setWidth(300);
		c.setHeight(300);

		
		FileOutputStream os=new FileOutputStream("chart.svg");
		
		ChartImage image=new ChartBatikImage(300,300);
		ChartGraphics g=null;
		g=image.getGraphics();
		c.doubleBuffering=false;
		c.paint(g);							
		image.saveToStream(null,os);		

		c.dispose();
		
		System.out.println("File chart.svg created");
		
		}

		catch(Exception e) {
		
			e.printStackTrace();
		}
		
		System.exit(0);
	}
	
	

}
